/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.com.pps.web.common.component.table;

/**
 *
 * @author DaiMX
 */
import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public abstract class AbstractTableItem
  implements Serializable
{
  public static final int INVERT_SELECTED = 2;
  public static final int ALL_SELECTED = 1;
  public static final int NONE_SELECTED = 0;
  protected boolean m_selected;
  protected boolean m_isNew;

  public boolean getSelected()
  {
    return this.m_selected;
  }

  public void setSelected(boolean pm_selected)
  {
    this.m_selected = pm_selected;
  }

  public boolean getIsNew()
  {
    return this.m_isNew;
  }

  public void setIsNew(boolean pm_isNew)
  {
    this.m_isNew = pm_isNew;
  }

  public void load(ResultSet pm_resultSet)
    throws SQLException
  {
    throw new IllegalStateException("This method should be re-defined.");
  }

  public static void selection(List pm_list, int pm_value)
  {
    for (int i = 0; i < pm_list.size(); ++i)
    {
      AbstractTableItem tableItem = (AbstractTableItem)pm_list.get(i);
      if (pm_value == 2)
        tableItem.setSelected(!tableItem.getSelected());
      else
        tableItem.setSelected(pm_value != 0);
    }
  }
  
  
}
